package com.ruoyi.bms.controller;

import com.ruoyi.bms.domain.BmsBooks;
import com.ruoyi.bms.domain.BmsUserUpload;
import com.ruoyi.bms.domain.BmsUserUploadVO;
import com.ruoyi.bms.service.IBmsUserUploadService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户上传管理Controller
 * 
 * @author ruoyi
 * @date 2025-01-12
 */
@RestController
@RequestMapping("/brs/userUpload")
public class BmsUserUploadController extends BaseController
{
    @Autowired
    private IBmsUserUploadService brsUserUploadService;

    /**
     * 查询用户上传管理列表
     */
    @PreAuthorize("@ss.hasPermi('brs:userUpload:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsUserUpload bmsUserUpload)
    {
        startPage();
        List<BmsUserUploadVO> list = brsUserUploadService.selectBrsUserUploadListMS(bmsUserUpload);
        return getDataTable(list);
    }

    /**
     * 导出用户上传管理列表
     */
    @PreAuthorize("@ss.hasPermi('brs:userUpload:export')")
    @Log(title = "用户上传管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmsUserUpload bmsUserUpload)
    {
        List<BmsUserUpload> list = brsUserUploadService.selectBrsUserUploadList(bmsUserUpload);
        ExcelUtil<BmsUserUpload> util = new ExcelUtil<BmsUserUpload>(BmsUserUpload.class);
        util.exportExcel(response, list, "用户上传管理数据");
    }

    /**
     * 获取用户上传管理详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(brsUserUploadService.selectBrsUserUploadById(id));
    }

    /**
     * 新增用户上传管理
     */
    @PreAuthorize("@ss.hasPermi('brs:userUpload:add')")
    @Log(title = "用户上传管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsUserUpload bmsUserUpload)
    {
        return toAjax(brsUserUploadService.insertBrsUserUpload(bmsUserUpload));
    }


    /**
     * 删除用户上传管理
     */
    @PreAuthorize("@ss.hasPermi('brs:userUpload:remove')")
    @Log(title = "用户上传管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(brsUserUploadService.deleteBrsUserUploadByIds(ids));
    }
    @GetMapping("/getMylistBookManagement")
    public TableDataInfo getMylistBookManagement()
    {
        startPage();
        List<BmsBooks> list = brsUserUploadService.getMylistBookManagement();
        return getDataTable(list);
    }

}
